/*
  学习目标：父传子技术
  步骤：
     1. 准备父子组件
     2. 传: 父组件传
     3. 接: 子组件接
*/

// rcc
import React, { Component } from 'react';

export default class App extends Component {
  state = {
    money: 1000,
  };

  handleMakeMoney = () => {
    //  sst
    this.setState({
      money: this.state.money + 1000,
    });
  };

  render() {
    const { money } = this.state;
    return (
      <div>
        <button onClick={this.handleMakeMoney}>点我</button>
        <Child money={money}></Child>
      </div>
    );
  }
}

class Child extends Component {
  render() {
    // cp
    const { money } = this.props;
    return <div>爸爸给我钱了{money}</div>;
  }
}
